package com.user.util;

import com.user.model.entity.User;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class GetUserUtil {

    public static User loginUser(){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

        String token = request.getHeader("token");
        CatchUtil catchUtil = new CatchUtil();
        if (null != token){
            return (User) catchUtil.getCatch(token);
        }
        return null;
    }
}
